    // define the module we're working with
    // define the ctrl
    app.controller("roomController",["$http","$scope","$location",function ($http,$scope,$location) {
        console.log($scope.selectedChannel);
       

        var source = new EventSource('/room/'+$scope.selectedChannel+'/update');
            source.addEventListener('message', handleCallback, false);

         $scope.sendMessage = function(id){
             x = $scope.form;
            $http({method: 'POST', url: '/room/'+id+'/sendMessage',data:x}).
             success(function(data, status, headers, config) {
            if(status == 200)
            {

            }

          }).
          error(function(data, status, headers, config) {
            console.log("aaa");
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          });
        }

           var handleCallback = function (msg) {
            $scope.$apply(function () {
               // $scope.msg = JSON.parse(msg.data);
               $scope.channel.messages.push(msg.data);

            });
        };
    }]);


 /*app.controller("loginController", [ "$http", "$scope", function ( $http, $scope ){
    


}]);*/

